package com.project.weimi.activity;

import java.util.ArrayList;
import java.util.List;

import com.project.weimi.R;
import com.project.weimi.adapter.IntegralExchangeAdapter;
import com.project.weimi.entity.response.IntegralExchangeEntity;
import com.project.weimi.utils.SetClickListener;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ListView;
import android.widget.TextView;

public class IntegralExchangeActivity extends BaseActivity{

	private TextView tv_integral,tv_exchangeRecord;
	private ListView listView;
	private List<IntegralExchangeEntity> list;
	
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentViewWithBar(R.layout.activity_integral_exchange, "积分兑换");
		
		initView();
		initListData();
		
		
	}
	
	private void initView(){
		tv_integral = (TextView)findViewById(R.id.tv_integral);
		tv_exchangeRecord = (TextView)findViewById(R.id.tv_exchangeRecord);
		listView = (ListView)findViewById(R.id.listView);
		
		// 监听
		SetClickListener.setClickListener(listener, tv_integral,tv_exchangeRecord);
		
	}
	
	private OnClickListener listener = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			Intent intent = null;
			
			switch (v.getId()) {
			case R.id.tv_integral: // 跳转到“我的积分”页面
				intent = new Intent(IntegralExchangeActivity.this,MyIntegralActivity.class);
				break;
			case R.id.tv_exchangeRecord: // 跳转到“兑换记录”页面
				intent = new Intent(IntegralExchangeActivity.this,ExchangeRecordActivity.class);
				break;
			default:
				break;
			}
			startActivity(intent);
			
		}
	};
	
	private void initListData(){
		list = new ArrayList<IntegralExchangeEntity>();
		for (int i = 0; i < 6; i++) {
			list.add(new IntegralExchangeEntity(R.drawable.integral_exchange, "俏皮可爱OL兔女郎", "290兑换"));
		}
		
		IntegralExchangeAdapter adapter = new IntegralExchangeAdapter(this,list);
		listView.setAdapter(adapter);
	}
	
	@Override
	void setStatusBar(int statusBarColorRes) {
		super.setStatusBar(R.color.transparent_3);
	}
	
}
